def a = "woQu"
// 动态增加一个方法
a.metaClass.swapCase = {->  
	def sb = new StringBuffer()  
	println("before:"+delegate)
	delegate.each {  
		sb << (Character.isUpperCase(it as char) ? Character.toLowerCase(it as char) :   
	           Character.toUpperCase(it as char))  
	}  
	sb.toString()  
}  
def res = a.swapCase()
println(res)

//动态增加一个字段
a.metaClass.age = 10
println(a.age)



